import { createSSRApp } from 'vue'
// 导入 Pinia
import { createPinia } from 'pinia'

// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createPersistedState } from 'pinia-plugin-persistedstate'

import App from './App'
import '@/utils/utils'

export function createApp() {
	const app = createSSRApp(App)
	const pinia = createPinia()
	app.use(pinia)
	const customPiniaPluginPersistedState = createPersistedState({
		// 自定义存储器
		storage: {
			setItem(key, value) {
				return uni.setStorageSync(key, value)
			},
			getItem(key) {
				return uni.getStorageSync(key)
			},
		},
	})
	pinia.use(customPiniaPluginPersistedState)
	return {
		app,
	}
}
